<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" type="text/css"
	href="../EXT4/resources/css/ext-all.css" />
<link rel="stylesheet" type="text/css" href="../css/style.css" />
<script type="text/javascript" src="../script/jquery.js"></script>
<script type="text/javascript">

function getDate() {
	var date = new Date();
	return date.getFullYear() + "-" + (date.getMonth()+1) + "-" + date.getDate();
}


function setDate() {
	var date1 = document.getElementById('date1');
	var date2 = document.getElementById('date2');
	
	if(date1 == undefined || date2 == undefined) return;
	date1.innerHTML = getDate();
	date2.innerHTML = getDate();
}

function setDisabled(obj, index) {
	if(index<3){
		var subject = document.getElementsByName('elects['+index+'].oaSubject.id')[0];
		var price = document.getElementsByName('elects['+index+'].price')[0];
	}else{
		index -= 3;
		var subject = document.getElementsByName('pelects['+index+'].oaSubject.id')[0];
		var price = document.getElementsByName('pelects['+index+'].price')[0];
	}
	
	if(subject == undefined || price == undefined) return;
	if(obj.checked) {
		subject.disabled = '';
		price.disabled = '';
	} else {
		subject.disabled = 'disabled';
		price.disabled = 'disabled';
	}
	
	
	
}


function options() {
	$('#pre_sub_id').html('');
	$.ajax({
		type: 'post',
		url: '../service/subject_allpre',
		dataType: 'json',
		success: function (data) {
			
			$.each(data.root, function(index, value) {
				$('#pre_sub_id').append('<option value="'+value.id+'">'+value.displayName+'</option>');
			});
		}
		
	});
}
</script>
</head>
<body onload="setDate()">
	
	<form action="printContract" method="post">
	<p align="center"><b>报名合同 </b></p>
    <b>尊敬的<input type="text" name="parent"/>家长： </b><br /><br />
    <b>很高兴您为孩子选择了小舞台！ 您给孩子报名的是<input type="text" id="startDate" name="startDate"/>开始的小舞台如下课程： </b><br /><br />
	<table>
	<s:iterator value="subjects" status="i">
		<input type="hidden" value="<s:property value='id'/>" name="elects[${i.index }].oaSubject.id" disabled="disabled"/>
		<tr>
		<td width="33%">
			<input type="checkbox" onchange="setDisabled(this, ${i.index })"/>
			<s:property value="displayName"/>
		</td>
		<td width="33%">原价 ￥<s:property value="price"/></td>
		<td width="33%">实收 ￥<input type="text" name="elects[${i.index }].price" disabled="disabled"/></td>
		</tr>
	</s:iterator>
		<tr>
		<td width="33%">
			另赠送
		</td>
		<s:iterator value="subjects" status="j">
			<input type="hidden" value="<s:property value='id'/>" name="pelects[${j.index }].oaSubject.id" disabled="disabled"/>
			<tr>
			<td width="33%">
				<input type="checkbox" onchange="setDisabled(this, ${j.index }+3)"/>
				<s:property value="displayName"/>
			</td>
			<td width="33%">价值 ￥<input type="text" name="pelects[${j.index }].price" disabled="disabled"/></td>
			</tr>
		</s:iterator>
		</tr>
	</table>
		<jsp:include page="/signup/contract.html" flush="false"></jsp:include><br/><br/><br/>
	<table width="100%">
		<tr>
			<td width="50%">
				<b>监护人签名：</b>
			</td>
			<td width="50%">
				<b>培训中心：</b>
			</td>
		</tr>
		<tr>
			<td>
				<b>日期：</b><span id="date1"></span>
			</td>
			<td>
				<b>日期：</b><span id="date2"></span>
			</td>
		</tr>
	</table>
	<div style = "text-align:right;">
		<input type="submit" value="打印" style="width:80px;height:40px">
	</div>
	</form>
</body>
</html>